[XM] Move 'xm sysrq' into main.py
authoratse@norwich.uk.xensource.com <atse@norwich.uk.xensource.com>
Fri, 22 Sep 2006 15:32:30 +0000 (16:32 +0100)
committeratse@norwich.uk.xensource.com <atse@norwich.uk.xensource.com>
Fri, 22 Sep 2006 15:32:30 +0000 (16:32 +0100)
* There's not need for sysrq to be in its own file.
* Bonus advantage: can use arg_check rather than gopts for argument
  validation.

Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xm/main.py
tools/python/xen/xm/sysrq.py [deleted file]

index 2bf6f80aeba2d21a771ac4a8b79c7a7eaa85516a..24e165ac66cab492187066d7ac436ce781df357d 100644 (file)
@@ -1010,6 +1010,12 @@ def xm_uptime(args):
 
         print upstring
 
+def xm_sysrq(args):
+    arg_check(args, "sysrq", 2)
+    dom = args[0]
+    req = args[1]
+    server.xend.domain.send_sysrq(dom, req)    
+
 def xm_top(args):
     arg_check(args, "top", 0)
 
@@ -1318,6 +1324,7 @@ commands = {
     "restore": xm_restore,
     "save": xm_save,
     "shutdown": xm_shutdown,
+    "sysrq": xm_sysrq,
     "uptime": xm_uptime,
     "list": xm_list,
     # memory commands
@@ -1359,7 +1366,6 @@ commands = {
 IMPORTED_COMMANDS = [
     'create',
     'migrate',
-    'sysrq',
     'labels',
     'addlabel',
     'cfgbootpolicy',
diff --git a/tools/python/xen/xm/sysrq.py b/tools/python/xen/xm/sysrq.py
deleted file mode 100644 (file)
index d17596f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# (C) Matthew Bloch <matthew@bytemark.co.uk> 2004
-# Copyright (C) 2005 XenSource Ltd
-
-"""Domain sysrq.
-"""
-
-from xen.xend.XendClient import server
-from xen.xm.opts import *
-
-gopts = Opts(use="""[DOM] [letter]
-
-Sends a Linux sysrq to a domain.
-""")
-
-gopts.opt('help', short='h',
-         fn=set_true, default=0,
-         use="Print this help.")
-
-def main(argv):
-    opts = gopts
-    args = opts.parse(argv)
-
-    if len(args) < 1:
-        raise OptionError('Missing domain argument')
-    if len(args) < 2:
-        raise OptionError('Missing sysrq character')
-
-    dom = args[0]
-    req = ord(args[1][0])
-    server.xend.domain.send_sysrq(dom, req)